<template>
  <div>
    <!-- 选择知识点 -->
    <el-select
      v-model="value"
      clearable
      filterable
      placeholder="请选择"
      @change="handleChange"
    >
      <el-option
        v-for="item in options"
        :key="item.id"
        :label="item.name"
        :value="item.id"
      >
      </el-option>
    </el-select>
  </div>
</template>
<script>
import { sysKnowledgeQuery } from '@/api/admin/courseLibrary/sysKnowledge.js'
export default {
  data() {
    return {
      value: '',
      options: [],
    }
  },
  props: ['defaultValue'],
  watch: {
    defaultValue(newVal, oldVal) {
      this.value = newVal
    },
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      sysKnowledgeQuery().then((res) => {
        this.options = res.data.data
        this.value = this.defaultValue
      })
    },
    handleChange(value) {
      this.$emit('e-knowledgeData', value)
    },
  },
}
</script>